package com.example.module_web.adapter;

import android.content.Context;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

import com.example.module_web.R;
import com.example.module_web.beans.Buyer;

import java.util.HashMap;
import java.util.List;

/**
 * Created by ASUS on 2018/3/13.
 */

public class BuyerAdapter extends FormAdapter<Buyer> {
    private static final String TAG = "bug";

    public BuyerAdapter(Context context, List<Buyer> items) {
        super(context, items);
    }

    @Override
    public HashMap<String, View> onBindItemViewId(HashMap<String, View> holder, View itemView) {
        Log.e(TAG, "onBindItemViewId: 0");
        holder.put(NUM,itemView.findViewById(R.id.item_form_num));
        holder.put(ACCOUNT,itemView.findViewById(R.id.item_form_account));
        holder.put(REMARK,itemView.findViewById(R.id.item_form_remark));
        holder.put(ALLPOINTS,itemView.findViewById(R.id.item_form_allpoints));
        holder.put(USEPOINTS,itemView.findViewById(R.id.item_form_usepoints));
        Log.e(TAG, "onBindItemViewId: 1");
        return holder;
    }

    @Override
    protected int setItemLayoutId() {
        return R.layout.web_item_frag10_buyer;
    }

    @Override
    protected void onBindFormData(HashMap<String, View> holder, Object o) {
        Log.e(TAG, "onBindFormData: 2");
        Buyer buyer = (Buyer) o;
        ((TextView)holder.get(NUM)).setText(String.format("%s)", String.valueOf(buyer.getNumber())));
        ((TextView)holder.get(ACCOUNT)).setText(buyer.getAccount());
        ((TextView)holder.get(REMARK)).setText(buyer.getRemark());
        ((TextView)holder.get(ALLPOINTS)).setText(String.valueOf(buyer.getAllPoints()));
        ((TextView)holder.get(USEPOINTS)).setText(String.valueOf(buyer.getUsedPoints()));
        Log.e(TAG, "onBindFormData: 3");
    }
}
